package com.whfc.iot.fse.lift.processor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import static com.whfc.iot.fse.lift.entity.LiftConst.*;

/**
 * @Description:
 * @author: xugcheng
 * @version: 1.0
 * @date: 2019/8/29 15:13
 */
@Component
public class LiftUpMsgProcessorFactory {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private LiftUpMsgProcessor0x01 processor0x01;

    @Autowired
    private LiftUpMsgProcessor0x10 processor0x10;

    @Autowired
    private LiftUpMsgProcessor0x12 processor0x12;

    @Autowired
    private LiftUpMsgProcessor0x13 processor0x13;

    /**
     * 获取消息处理器
     *
     * @param cmd
     * @return
     */
    public LiftUpMsgProcessor getMsgProcessor(int cmd) {
        LiftUpMsgProcessor processor = null;
        switch (cmd) {
            case LIFT_UP_CMD_0X01:
                processor = processor0x01;
                break;
            case LIFT_UP_CMD_0X10:
                processor = processor0x10;
                break;
            case LIFT_UP_CMD_0X12:
                processor = processor0x12;
                break;
            case LIFT_UP_CMD_0X13:
                processor = processor0x13;
                break;
            default:
                logger.info("无法解析的指令,cmd:{}", cmd);
        }
        return processor;
    }
}
